package com.liujit.validator.config;

import org.hibernate.validator.HibernateValidator;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import javax.validation.Validation;
import javax.validation.Validator;
import javax.validation.ValidatorFactory;

/**
 * @author: liujun
 * @date: 2021/6/18 1:40 下午
 * @description: Hibernate Validator配置
 */
@Configuration
public class ValidationConfig {

    /**
     * 开启快速校验配置
     *
     * @return
     * @author: liujun
     * @date: 2021/6/18 1:49 下午
     */
    @Bean
    public Validator Validator() {
        ValidatorFactory validatorFactory = Validation.byProvider(HibernateValidator.class).configure().failFast(true)
                .buildValidatorFactory();
        return validatorFactory.getValidator();
    }
}
